Skip to content

fix: give each request a time limit, and let the user cancel an upload - #527

Merged
pdevito3 merged 6 commits into
mainfrom
fix/request-timeouts
Nov 15, 2026
Merged

pdevito3 merged 6 commits into
mainfrom
fix/request-timeouts

Conversation

@pdevito3

@pdevito3 pdevito3 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Why

A hung Server or a dropped network kept the SPA pending with no end. An upload had no cancel. Now each request has a time limit at the BFF and in the SPA, and the user can cancel an upload.

What changed

  • The BFF forwarder has a 30 s idle limit, and a multipart upload has 5 min (Bff:Proxy options, one row per content type). A request that reaches its limit gets a 504.
  • The SPA API client stops a request after 35 s, or 10 min for an upload. A 504 or a timeout shows one message: "The server did not answer in time. Reload the page to see the latest data, then try again."
  • During an upload, the Files section shows a "Cancel upload" button. It stops the request, goes back to idle, moves the focus to the upload button, and shows no toast.

Scope

  • Covers every proxied API call and the attachment upload.
  • Does not add retries or a dedupe of uploads.

Tradeoffs

  • No dedupe. If the Server already saved a file when the user cancels, the file stays, and a second upload adds a copy. The Limits section of the attachments doc says so. A dedupe key costs more than a rare duplicate that the user can delete.
  • The upload limit is a BFF option and not the Server's Attachments:AddTimeout, because main has no such setting. When feat(server): sweep the objects that no row names #526 lands, set the BFF value from it.
  • The SPA limits count the total time, so they are a little longer than the BFF idle limits. The 504 of the BFF comes first, and the SPA limit stops the wait only when the BFF itself does not answer.

Blast Radius

The change touches all proxied API calls. A Server call that sends no bytes for 30 s now fails with a 504. The Server has no streaming or long-poll endpoint today.

Verification

  • Before the fix, the new BFF, Playwright claim, and cancel tests failed. After it, they pass, and each new Playwright test passed 10 of 10 runs with --repeat-each=10.
  • The tests of a hung request set a short limit, so they do not wait for the real ones. The BFF test sets Bff:Proxy:ActivityTimeout to 1 s (30 s before, now 1.8 s). The Playwright claim test cuts the browser limit of the claim request to 1 s with shortenRequestTimeLimit (36.1 s before, now 1.5 to 2.5 s). The browser counts the XHR limit, so page.clock cannot reach it. A BFF test and the SPA unit test pin the defaults: 30 s, 5 min, 35 s, and 10 min. With the limit code removed, each shortened test fails.
  • The solution builds with 0 warnings. 516 BFF tests pass, and pnpm lint, pnpm build, pnpm test (874 tests), join.spec.ts with --repeat-each=10 (540 of 540), and pnpm test:e2e (360 tests) pass.
  • On the live stack, a throttled real upload stopped when the user pressed Cancel upload, with no toast. Light, dark, and narrow screenshots look correct.

…no cancel

A hung Server keeps a request of the BFF for 100 s, a request of the SPA
with no answer waits with no end, and the upload has no Cancel button.
These tests fail until the fix.
The BFF forwarder waits Bff:Proxy:ActivityTimeout (30 s) with no
progress, and Bff:Proxy:UploadActivityTimeout (5 min) for a multipart
form, in place of the 100 s default of YARP. A table maps each content
type to its limit, and routing picks the forwarder by Content-Type.

apiClient stops a request after 35 s, and an upload after 10 min, so
the 504 of the BFF comes first. A 504 and a stopped request show
timedOutMessage. The Files section shows Cancel upload while an upload
is on the way. A cancel aborts the request and shows no message.
@pdevito3

Copy link
Copy Markdown
Owner Author

Review gate (thermo-nuclear review, opus): no high or medium findings. Low findings that stay open, with reasons:

  • The SPA limit counts total time and the BFF limit counts idle time, so a token refresh or a slow stream can make the SPA stop first. Both paths show the same message, so the user sees no difference.
  • config.timeout ||= ignores an explicit timeout: 0. This is on purpose: the axios instance default is 0, so ??= would never set a limit. A request cannot opt out of the limit.
  • The BFF hang test waits the real 30 s default. It proves the shipped value, not a test override. The cost is about 30 s of suite time.
  • The join timeout test waits about 36 s, because the XHR timeout is native and Playwright's clock cannot fake it. test.slow() covers it, and it passed 10 of 10 runs.

Fixed after the review: docs/messages.md, docs/frontend.md, and docs/backend/attachments.md now name the time-out message and the Cancel upload button.

…the default limits

The BFF test sets Bff:Proxy:ActivityTimeout to 1 s, and the functional test cuts the
browser time limit of the claim request to 1 s. A BFF test and the unit test of the
SPA pin the defaults of 30 s, 5 min, 35 s, and 10 min.
@pdevito3

Copy link
Copy Markdown
Owner Author

The two slow tests in the low findings are fixed in d6b71c6. The BFF hang test sets Bff:Proxy:ActivityTimeout to 1 s (30 s before, now 1.8 s). The Playwright claim test cuts the browser limit of the claim request to 1 s (36.1 s before, now about 2 s). A BFF test and the SPA unit test pin the defaults of 30 s, 5 min, 35 s, and 10 min. With the limit code removed, each shortened test fails.

@pdevito3
pdevito3 merged commit fb2e771 into main Nov 15, 2026
23 checks passed
@pdevito3
pdevito3 deleted the fix/request-timeouts branch November 15, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant